<template>
  <div class="login01">
    <el-form ref="form" :model="form" label-width="50px">
      <el-form-item label="账户" prop="user">
        <el-input v-model="form.user" auto-complete="off"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="pass">
        <el-input type="password" v-model="form.pass" auto-complete="off"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitlogin">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  name: "login",
  data() {
    return {
      form: {
        user: "",
        pass: ""
      }
    };
  },
  methods: {
    submitlogin() {
      this.axios
        .get("/loginquest", {
          params: {
            user: this.form.user,
            pass: this.form.pass
          }
        })
        .then(response => {
          if (response.data.permition == 1) {
            return (window.location.href = "/protected");
          }
          if (response.data.permition == 0) {
            this.$message("登录成功！");
          }
        })
        .catch(error => {
          this.console.log(error);
        });
    }
  }
};
</script>
<style>
.login01 {
  margin-right: 10px;
  margin-left: 10px;
}
</style>
